import 'package:seedfour/generated/json/base/json_convert_content.dart';
import 'package:seedfour/app/models/invoice_entity.dart';

InvoiceEntity $InvoiceEntityFromJson(Map<String, dynamic> json) {
  final InvoiceEntity invoiceEntity = InvoiceEntity();
  final String? withdrawMode = jsonConvert.convert<String>(
      json['withdrawMode']);
  if (withdrawMode != null) {
    invoiceEntity.withdrawMode = withdrawMode;
  }
  final String? withdrawAcct = jsonConvert.convert<String>(
      json['withdrawAcct']);
  if (withdrawAcct != null) {
    invoiceEntity.withdrawAcct = withdrawAcct;
  }
  final String? withdrawBank = jsonConvert.convert<String>(
      json['withdrawBank']);
  if (withdrawBank != null) {
    invoiceEntity.withdrawBank = withdrawBank;
  }
  final String? withdrawName = jsonConvert.convert<String>(
      json['withdrawName']);
  if (withdrawName != null) {
    invoiceEntity.withdrawName = withdrawName;
  }
  final String? orderRemark = jsonConvert.convert<String>(json['orderRemark']);
  if (orderRemark != null) {
    invoiceEntity.orderRemark = orderRemark;
  }
  final InvoiceOrderAttach? orderAttach = jsonConvert.convert<
      InvoiceOrderAttach>(json['orderAttach']);
  if (orderAttach != null) {
    invoiceEntity.orderAttach = orderAttach;
  }
  final List<InvoiceOrderAttach>? orderAttachs = (json['orderAttachs'] as List<
      dynamic>?)
      ?.map(
          (e) =>
      jsonConvert.convert<InvoiceOrderAttach>(e) as InvoiceOrderAttach)
      .toList();
  if (orderAttachs != null) {
    invoiceEntity.orderAttachs = orderAttachs;
  }
  final List<InvoiceRelateCases>? relateCases = (json['relateCases'] as List<
      dynamic>?)
      ?.map(
          (e) =>
      jsonConvert.convert<InvoiceRelateCases>(e) as InvoiceRelateCases)
      .toList();
  if (relateCases != null) {
    invoiceEntity.relateCases = relateCases;
  }
  final List<InvoiceItemEntity>? invoiceList = (json['invoiceList'] as List<
      dynamic>?)
      ?.map(
          (e) => jsonConvert.convert<InvoiceItemEntity>(e) as InvoiceItemEntity)
      .toList();
  if (invoiceList != null) {
    invoiceEntity.invoiceList = invoiceList;
  }
  return invoiceEntity;
}

Map<String, dynamic> $InvoiceEntityToJson(InvoiceEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['withdrawMode'] = entity.withdrawMode;
  data['withdrawAcct'] = entity.withdrawAcct;
  data['withdrawBank'] = entity.withdrawBank;
  data['withdrawName'] = entity.withdrawName;
  data['orderRemark'] = entity.orderRemark;
  data['orderAttach'] = entity.orderAttach?.toJson();
  data['orderAttachs'] = entity.orderAttachs?.map((v) => v.toJson()).toList();
  data['relateCases'] = entity.relateCases?.map((v) => v.toJson()).toList();
  data['invoiceList'] = entity.invoiceList?.map((v) => v.toJson()).toList();
  return data;
}

extension InvoiceEntityExtension on InvoiceEntity {
  InvoiceEntity copyWith({
    String? withdrawMode,
    String? withdrawAcct,
    String? withdrawBank,
    String? withdrawName,
    String? orderRemark,
    InvoiceOrderAttach? orderAttach,
    List<InvoiceOrderAttach>? orderAttachs,
    List<InvoiceRelateCases>? relateCases,
    List<InvoiceItemEntity>? invoiceList,
  }) {
    return InvoiceEntity()
      ..withdrawMode = withdrawMode ?? this.withdrawMode
      ..withdrawAcct = withdrawAcct ?? this.withdrawAcct
      ..withdrawBank = withdrawBank ?? this.withdrawBank
      ..withdrawName = withdrawName ?? this.withdrawName
      ..orderRemark = orderRemark ?? this.orderRemark
      ..orderAttach = orderAttach ?? this.orderAttach
      ..orderAttachs = orderAttachs ?? this.orderAttachs
      ..relateCases = relateCases ?? this.relateCases
      ..invoiceList = invoiceList ?? this.invoiceList;
  }
}

InvoiceOrderAttach $InvoiceOrderAttachFromJson(Map<String, dynamic> json) {
  final InvoiceOrderAttach invoiceOrderAttach = InvoiceOrderAttach();
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    invoiceOrderAttach.name = name;
  }
  final String? url = jsonConvert.convert<String>(json['url']);
  if (url != null) {
    invoiceOrderAttach.url = url;
  }
  return invoiceOrderAttach;
}

Map<String, dynamic> $InvoiceOrderAttachToJson(InvoiceOrderAttach entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['name'] = entity.name;
  data['url'] = entity.url;
  return data;
}

extension InvoiceOrderAttachExtension on InvoiceOrderAttach {
  InvoiceOrderAttach copyWith({
    String? name,
    String? url,
  }) {
    return InvoiceOrderAttach()
      ..name = name ?? this.name
      ..url = url ?? this.url;
  }
}

InvoiceRelateCases $InvoiceRelateCasesFromJson(Map<String, dynamic> json) {
  final InvoiceRelateCases invoiceRelateCases = InvoiceRelateCases();
  final String? caseId = jsonConvert.convert<String>(json['caseId']);
  if (caseId != null) {
    invoiceRelateCases.caseId = caseId;
  }
  final String? caseName = jsonConvert.convert<String>(json['caseName']);
  if (caseName != null) {
    invoiceRelateCases.caseName = caseName;
  }
  final String? time = jsonConvert.convert<String>(json['time']);
  if (time != null) {
    invoiceRelateCases.time = time;
  }
  return invoiceRelateCases;
}

Map<String, dynamic> $InvoiceRelateCasesToJson(InvoiceRelateCases entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['caseId'] = entity.caseId;
  data['caseName'] = entity.caseName;
  data['time'] = entity.time;
  return data;
}

extension InvoiceRelateCasesExtension on InvoiceRelateCases {
  InvoiceRelateCases copyWith({
    String? caseId,
    String? caseName,
    String? time,
  }) {
    return InvoiceRelateCases()
      ..caseId = caseId ?? this.caseId
      ..caseName = caseName ?? this.caseName
      ..time = time ?? this.time;
  }
}

InvoiceItemEntity $InvoiceItemEntityFromJson(Map<String, dynamic> json) {
  final InvoiceItemEntity invoiceItemEntity = InvoiceItemEntity();
  final String? invoiceNo = jsonConvert.convert<String>(json['invoiceNo']);
  if (invoiceNo != null) {
    invoiceItemEntity.invoiceNo = invoiceNo;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    invoiceItemEntity.name = name;
  }
  final String? source = jsonConvert.convert<String>(json['source']);
  if (source != null) {
    invoiceItemEntity.source = source;
  }
  final String? cat1 = jsonConvert.convert<String>(json['cat1']);
  if (cat1 != null) {
    invoiceItemEntity.cat1 = cat1;
  }
  final String? cat2 = jsonConvert.convert<String>(json['cat2']);
  if (cat2 != null) {
    invoiceItemEntity.cat2 = cat2;
  }
  final String? sfUrl = jsonConvert.convert<String>(json['sfUrl']);
  if (sfUrl != null) {
    invoiceItemEntity.sfUrl = sfUrl;
  }
  final String? url = jsonConvert.convert<String>(json['url']);
  if (url != null) {
    invoiceItemEntity.url = url;
  }
  final String? totalAmount = jsonConvert.convert<String>(json['totalAmount']);
  if (totalAmount != null) {
    invoiceItemEntity.totalAmount = totalAmount;
  }
  return invoiceItemEntity;
}

Map<String, dynamic> $InvoiceItemEntityToJson(InvoiceItemEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['invoiceNo'] = entity.invoiceNo;
  data['name'] = entity.name;
  data['source'] = entity.source;
  data['cat1'] = entity.cat1;
  data['cat2'] = entity.cat2;
  data['sfUrl'] = entity.sfUrl;
  data['url'] = entity.url;
  data['totalAmount'] = entity.totalAmount;
  return data;
}

extension InvoiceItemEntityExtension on InvoiceItemEntity {
  InvoiceItemEntity copyWith({
    String? invoiceNo,
    String? name,
    String? source,
    String? cat1,
    String? cat2,
    String? sfUrl,
    String? url,
    String? totalAmount,
  }) {
    return InvoiceItemEntity()
      ..invoiceNo = invoiceNo ?? this.invoiceNo
      ..name = name ?? this.name
      ..source = source ?? this.source
      ..cat1 = cat1 ?? this.cat1
      ..cat2 = cat2 ?? this.cat2
      ..sfUrl = sfUrl ?? this.sfUrl
      ..url = url ?? this.url
      ..totalAmount = totalAmount ?? this.totalAmount;
  }
}